<?php
namespace App\Http\Logic;

use App\Models\AdminRegion;

class RegionLogic extends CommonLogic
{
    public static function getName($id = "")
    {
        if ($id == "") {
            return "";
        }

        $res = AdminRegion::find($id);

        return $res -> name;
    }
    public static function getProvinces()
    {
        return AdminRegion::where('level', 'province')->pluck('name', 'id');
    }

    public static function getCities($provinceId)
    {
        return AdminRegion::where('parent_id', $provinceId)->pluck('name', 'id');
    }

    public static function getDistricts($cityId)
    {
        return AdminRegion::where('parent_id', $cityId)->pluck('name', 'id');
    }
}
